<template>
    <div>
    	<div class="graybg"></div>
		<div class="header header_bg">
  			<div class="header_left">
  				<i onclick="javascript:history.back(-1)" class="iconfont baiColor">&#xe612;</i>
  			</div>
  			<div class="header_center">
  				<span class="baiColor">支付密码</span>
  			</div>
  		</div>

  		<div class="center">
  			<form action="" method="post" style="padding-top: 52px;">
	  			<input type="password"  placeholder="支付密码" v-model="pass"  />
	 
	  			<input type="password"  placeholder="确认支付密码" v-model="surepass" />
	  		</form>
  			<div class="enter button" @click="updatepass">确定</div>
  		</div>
    </div>

</template>


<script>
    export default{
    	props:["verifyPass","verifyBalanceobj","remainingSum"],
        data(){
            return {
				pass:'',
				surepass:'',
				transferType:[], //转张类型总数据
				transferTypechecked:"" //转张类型：hzh活积分转活积分；hzy活积分转余额
            }
        },
        mounted(){
        	var remainingSumtype = this.remainingSum.transferType;
        	this.transferType.push(remainingSumtype);
        	for(var i=0,len=this.transferType.length;i<len; i++){
        		if(this.transferType[i] != undefined){
        			this.transferTypechecked = this.transferType[i]
        		}
        	}
        	console.log(this.transferTypechecked)
        },
        methods:{
        	updatepass:function(){
        		var remainingSum = this.remainingSum;	//余额转账
        		var pass = this.pass;
        		var surepass = this.surepass;
        		//判断密码是否为空？是否相等？
        		if(pass == surepass){
					var info = window.localStorage.data;
					var params = new URLSearchParams();
					params.append('token', info);	//客户秘钥（信息）
					params.append('pwd',pass);
					this.$axios({
					   url:"One/Fun/verifyPayPwd",
						method:"post",
						data:params
					   }).then((res)=>{
					   	//验证密码输入是否正确，如果正确则转账成功；
					   	if(res.data.status == 1){
					   		let transferType = this.transferTypechecked;	//转张类型：yz余额转账
					   		
							if(transferType == "yz"){	//活积分转活积分
								let gathering = remainingSum.s_user_id;
								let gatheringmoney = remainingSum.price;
								let type = remainingSum.type;
								var params = new URLSearchParams();
								params.append('token', info);	//客户秘钥（信息）
								params.append('s_user_id',gathering);
								params.append('price',gatheringmoney);
								params.append('type',type);
								this.$axios({
								   url:"Home/Money/money_zhuan",
									method:"post",
									data:params
								}).then((res)=>{
									if(res.data.code == 1){
										alert("转账成功")
										this.$router.push("wShares");
									}else if(res.data.code == 0){
										alert("转账失败")
									}else if(res.data.code == 3){
										alert("缺少参数")
									}else if(res.data.code == 4){
										alert("余额不足")
									}else if(res.data.code == 4){
										alert("收款用户不存在")
									}
								}).catch((err)=>{
									console.log(err)		
								})
							}
							
							
					   	}else{
					   		alert("密码输入错误，请重新输入");
					   		this.pass = "";
        					this.surepass = "";
					   	}
					}).catch((err)=>{
						alert(err)		
					})
        			
        		}else if(pass == "" || surepass == ""){
        			alert("密码不能为空");
        		}else{
        			alert("两次输入密码不一致，请重新输入");
        			this.pass = "";
        			this.surepass = "";
        		}
        		
        	}
        },
    }

</script>

<style scoped="scoped">
@import "../css/public.css";
.center{
	width: 95%;
	margin: 0 auto;
}
.center form{
	width: 100%;
}
.center form input{
	padding-left: 10px;
	display: block;
	background: #FFFFFF;
	height: 14px;
	width: 97%;
	margin: 10px 0;
	height: 40px;
	line-height: 38px;
}

input::-webkit-input-placeholder{
	color: #999;
	font-size: 14px;
	line-height: 38px;
}
.center .enter{
	background: #F3961F;
	font-size: 18px;
	color: #FCFCFC;
	margin-top:128px;
	line-height: 30px;
}
</style>
